home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / KEYBOARD.SWG / 0077_pgdn-pgup.pas < prev    next >
Pascal/Delphi Source File  |  1994-05-25  |  2KB  |  74 lines

  1.  
  2. {
  3. Here is an (TP 5.5) atom that will help you grab "extended"
  4. keyboard scancodes.  I think the problem you're having has to
  5. do with the fact that you can't trap hot keys inside ReadLn,
  6. yes?  You need to build a set of routines that support
  7. a-key-at-a-time input into a string, echoing the keystrokes
  8. to the screen as you go.  This "atom" just handles keystrokes-
  9. the string handling is probably _WAY_ too long to list here.
  10. }
  11.  
  12. Program _;
  13.  
  14. Uses Crt;
  15.  
  16. Type KeyType = (Ascii,ExtendedKey,Escape);
  17.  
  18. Var
  19. KtGlb : KeyType;
  20. ChGlb : Char;
  21.  
  22. Procedure GetExtKey( Var Ch:Char;  Var Kt:KeyType; );
  23. Begin
  24.   Repeat
  25.   Until KeyPressed;
  26.   Kt := Ascii;
  27.   Ch := ReadKey;
  28.   If (Ch=#0) Then
  29.     Begin
  30.       Ch := ReadKey;
  31.       If (Ord(Ch)=27) Then Kt := Escape Else Kt := ExtendedKey;
  32.     End;
  33. End;
  34.  
  35. Procedure Main
  36. Begin
  37.   Write('Press a key.');
  38.   ChGlb := #0;
  39.   KtGlb := Ascii;
  40.   Repeat
  41.     GotoXY(13,1);
  42.     GetExtKey(ChGlb,KtGlb);
  43.     GotoXY(1,2);
  44.     ClrEol;
  45.     GotoXY(1,2);
  46.     Case KtGlb Of
  47.       Ascii       : Write('Ascii,    ');
  48.       ExtendedKey : Write('Extended, ');
  49.       Escape      : Write('Escape,   ')
  50.     End;
  51.     Write('Scancode = ',Ord(Ch));
  52.   Until (Kt=Escape);
  53.   WriteLn;
  54.   WriteLn;
  55. End;
  56.  
  57. Begin
  58.   ClrScr;
  59.   Main;
  60. End.
  61.  
  62. This should help you capture _any_ extended scan code from the keyboard.
  63. PgUp, PgDn, Ctrl-PgUp, Alt-Shft-F5, etc...  Chapter Seventeen of "Turbo
  64. Pascal 5.5, The Complete Reference" by O'Brien (Borland/Osborne/McGraw-
  65. Hill ISBN 0-07-881501-0) covers the issue of buffered string input pretty
  66. well.
  67.  
  68. And as for your next berrage of questions, "Turbo Pascal Advanced
  69. Techniques" by Ohlsen & Stoker (Que Corp. ISBN 0-88022-432-0) covers
  70. DOS windowing very nicely.  (Also many other goodies).
  71.  
  72. Hope it helped a little.
  73. David Kandrat
  74.